Closed
Bug 1379859
Opened 8 years ago
Closed 3 years ago
Rust code doesn't seem to interact well with MSVC incremental linker
Categories
(Firefox Build System :: General, enhancement)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: xidorn, Unassigned)
References
(Blocks 1 open bug)
Details
Copy from my email in dev-platform thread:
Not just compile time, but also the link time is high. Specifically, I suspect our linking strategy for Rust code doesn't interact well with MSVC's incremental linker, which slows down this final sequential step.
For that, I just did an experiment. In my local repo, when I remove all linking-related files from objdir/toolkit/library (to do a fresh linking), it takes ~1.7min for linking.
When I touch one cpp file (in my experiment, layout/style/nsCSSAnonBoxes.cpp which is a reasonable small cpp file I happen to open), it takes 6s to link, and size of xul.ilk (Incremental Linker File) increases by 856KB.
When I touch one rs file (in my experiment, servo/components/gecko_bindings/sugar/style_complex_color.rs which is a reasonable small rs file I happen to be familiar with), it takes ~2min to link (even longer than the fresh linking!) in addition to the compile time, and size of xul.ilk increases by 27.44MB. And after that, when I touch that cpp file again, it takes ~2.1min to link and size of xul.ilk increases by 54.64MB this time.
I suspect the more times you touch rs files, the longer linking would take, and I guess this is because we link all Rust code into a single library, and then static link it into xul.dll, which makes the linker do lots of wasteful work. There could also be some linker bug involves, though.
To mitigate this, we can probably avoid incremental linking when Rust code is touched. I also wonder if it is possible to avoid linking the whole gkrust into xul.dll at all and see if that makes things better. It would also be good to see if Rust developers have any advice for this situation.
Comment 1•8 years ago
|
||
Seems this should be filed against the rust compiler.
![]() |
||
Updated•8 years ago
|
Blocks: rust-great
Reporter | ||
Comment 2•8 years ago
|
||
(In reply to Mike Hommey [:glandium] from comment #1)
> Seems this should be filed against the rust compiler.
I'm not sure whether there is anything actionable for rust compiler... Probably ni? some rustc developer and see if they have any suggestion?
Comment 3•8 years ago
|
||
I don't see anything actionable on the build system end...
Reporter | ||
Comment 4•8 years ago
|
||
There are several things we can probably try in the build system, e.g.
* dynamic link gkrust for debug build and see if that helps (if possible)
* pass -INCREMENTAL:NO to link.exe to disable incremental linking when gkrust is rebuilt
Reporter | ||
Comment 5•8 years ago
|
||
Also it's probably worth checking how many API does gkrust expose. If there are too many, maybe stripping some of them can help... I'm just randomly guessing...
Updated•7 years ago
|
Product: Core → Firefox Build System
Comment 6•7 years ago
|
||
IIRC, incremental linking doesn't play well with static libraries, and we compile all of our Rust code into a static library. That being said, I'm not sure this is as important as it was previously, since lld-link does things differently (and is reportedly much faster even without incremental linking).
Comment 7•3 years ago
|
||
We don't use the MSVC linker anymore.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•